﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VirtualHost.Services;

namespace VirtualHost.WinForm {
    public partial class FrmSettings : WinFormBase {
         
        HostService service = new HostService();
        public FrmSettings(HostService service) {
            InitializeComponent();
            this.service = service;
            LoadData();
        }

        private void LoadData() {
            txtCertificate.Text = service.Settimgs.Certificate;
            txtCertificateKey.Text = service.Settimgs.CertificateKey;
            txtNginxPath.Text = service.Settimgs.NginxPath;

        }
        private void btnSave_Click(object sender, EventArgs e) {
            service.Settimgs.Certificate = txtCertificate.Text;
            service.Settimgs.CertificateKey = txtCertificateKey.Text;
            service.Settimgs.NginxPath = txtNginxPath.Text;
            service.SaveSettings();
            ShowInfoTip("配置保存成功！");
            DialogResult = DialogResult.OK;
        }

        private void btnClose_Click(object sender, EventArgs e) {
            this.Close();
        }
    }
}
